/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.raflik.queryxml.ui;

import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.util.RequestProcessor;

/**
 *
 * @author raflik
 */
public class MessageDisplayer implements Runnable {

    private NotifyDescriptor nd;

    private MessageDisplayer(NotifyDescriptor nd) {
        this.nd = nd;
    }

    public void run() {
        DialogDisplayer.getDefault().notify(nd);
    }


    private static void asyncDisplay(NotifyDescriptor nd) {
        final MessageDisplayer md = new MessageDisplayer(nd);
        RequestProcessor.getDefault().execute(md);

    }
    public static void showError(String msg) {
        final NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE);
        asyncDisplay(nd);
    }

    public static void showWarning(String msg) {
        final NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.WARNING_MESSAGE);
        asyncDisplay(nd);
    }

}
